package hu.szyrt.bug;


import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;

@SuppressWarnings("deprecation")
public class MainActivity extends TabActivity {
	
	private final static String TAB_CATEGORY = "category",
								TAB_MAP		 = "map",
								TAB_LIST	 = "list",
								TAB_TOURS	 = "tours",
								TAB_INFO	 = "info";
	
	private TabHost tabHost;
	private TabHost.TabSpec spec;
	private Intent intent;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        this.tabHost = getTabHost();  // The activity TabHost       

        // Category
        this.intent = new Intent(this, CategoryActivity.class);
        this.spec = tabHost.newTabSpec(TAB_CATEGORY)
        				   .setIndicator(getWidgetView(R.string.category, R.drawable.selector_tab_bar_category))
                           .setContent(intent);
        tabHost.addTab(spec);
        
        // Map
        this.intent = new Intent(this, MapsActivity.class);
        this.spec = tabHost.newTabSpec(TAB_MAP)
						   .setIndicator(getWidgetView(R.string.map, R.drawable.selector_tab_bar_map))
						   .setContent(intent);
        tabHost.addTab(spec);
        
        // List
        this.intent = new Intent(this, ListActivity.class);
        this.spec = tabHost.newTabSpec(TAB_LIST)
						   .setIndicator(getWidgetView(R.string.list, R.drawable.selector_tab_bar_list))
						   .setContent(intent);
        tabHost.addTab(spec);

        // Tours
        this.intent = new Intent(this, ToursActivity.class);
        this.spec = tabHost.newTabSpec(TAB_TOURS)
						   .setIndicator(getWidgetView(R.string.tours, R.drawable.selector_tab_bar_tours))
						   .setContent(intent);
        tabHost.addTab(spec);
        
        // Info
        this.intent = new Intent(this, InfoActivity.class);
        this.spec = tabHost.newTabSpec(TAB_INFO)
						   .setIndicator(getWidgetView(R.string.info, R.drawable.selector_tab_bar_info))
						   .setContent(intent);
        tabHost.addTab(spec);
        
        tabHost.setCurrentTab(0);
        
    }
    
    
    
    private View getWidgetView(int text_res, int icon_res){
    	View v = View.inflate(this, R.layout.tab_widget, null);
    	TextView t = (TextView)v.findViewById(R.id.tabWidgetText);
    	ImageView i = (ImageView)v.findViewById(R.id.tabWidgetImage);
    	t.setText(text_res);
    	i.setImageResource(icon_res);
    	return v;
    }
    
    
    
    
}